package au.com.langdale.gwt.client.pump;


import java.util.ArrayList;

import au.com.langdale.gwt.client.model.Model;
import au.com.langdale.gwt.client.remote.Batch;

import com.google.gwt.user.client.rpc.RemoteService;

/**
 * A general purpose service for reading and writing remote sequences 
 * of model objects (ie database tables).<p>
 * 
 *  Reading is performed in pages by the pull() method.<p>
 *   
 *  Creating, updating and deleting model objects is
 *  performed by the push() method.<p> 
 *  
 * @author adv
 *
 */
public interface Pump extends RemoteService {
	/**
	 * 
	 * Fetch a batch of objects from the database.
	 * 
	 * @param classname the type of the objects.
	 * @param first Position in database order from which to fetch.
	 * @param quota how many to fetch.
	 * @return a Batch with first and quota from this request
	 */
	public Batch pull(String classname, int first, int quota);
	/**
	 * 
	 * Fetch a batch of objects from the database.
	 * 
	 * @param classname the type of the objects.
	 * @param orderby the property on which to sort
	 * @param first Position in database order from which to fetch.
	 * @param quota how many to fetch.
	 * @return a Batch with first and quota from this request
	 */
	public Batch pull(String classname, String orderby, int first, int quota);
	/**
	 * 
	 *  Send modified and new objects back to the database.
	 * 
	 * @gwt.typeArgs updates <au.com.langdale.gwt.client.model.Model>
	 * @gwt.typeArgs deletes <au.com.langdale.gwt.client.model.Model>
	 */
	public void push(ArrayList updates, ArrayList deletes);
}
